package br.pucrio.inf.aaaong.models.form.converters.atomic;

public class FormIntegerConverter implements FormConverter<Integer> {
	private static final String INVALID_INTEGER_FORMAT_MESSAGE = "deve ter somente números.";

	public boolean canConvert(String str) {
		return str == null || str.matches("^\\d*$");
	}

	public Integer convert(String str) {
		if (str == null) return null;
		return Integer.valueOf(str);
	}

	@Override
	public String getConversionErrorMessage() {
		return INVALID_INTEGER_FORMAT_MESSAGE;
	}

}
